<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>设置</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/font-awesome.min.css" rel="stylesheet" />
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-1.12.4.min.js"></script>
		<script src="../js/app.js"></script>

		<script type="text/javascript">
			mui.init({
  				preloadPages:[{
    				id:'change_pass',
    				url:'setting/change_pass.html'
  				}]
			});
			
			mui.plusReady(function() {
				var user = JSON.parse(localStorage.getItem('user') || '{}');
				if(user){
					$("#user_name").text(user.USER_NAME);
					$("#login_name").text(user.LOGIN_NAME);
					$("#coop_name").text(user.COOP_NAME);
				}else {
					//app.toLogin();
//					var all = plus.webview.all();
//						
//					for(var i=0;i<=all.length -1 ; i++ ){ 
//					        if(all[i].id != plus.webview.getLaunchWebview().id){
//					        	all[i].close();
//					        	
//					        }
//	
//					} 
					
					plus.webview.getLaunchWebview().reload(true);
				}
				
				var detailPage = null;
  				if(!detailPage){
    					detailPage = plus.webview.getWebviewById('change_pass');
  				}
  				
  				var changePass = document.getElementById('change_pass');
					changePass.addEventListener('tap', function(event) {
						mui.openWindow({
    							id:'change_pass'
  						});
					});
					
					var loginOutButton = document.getElementById('login_out');
					loginOutButton.addEventListener('tap', function(event) {
						var user = JSON.parse(localStorage.getItem('user'));
						if(user){
							localStorage.setItem('user', '{}');
						}
//						var all = plus.webview.all();
//						
//						for(var i=0;i<=all.length -1 ; i++ ){ 
//						        if(all[i].id != plus.webview.getLaunchWebview().id){
//						        	all[i].close();
//						        	
//						        }
//		
//						} 
						plus.webview.getLaunchWebview().reload(true);
						//app.toLogin();
					});
					
					document.getElementById("checkUpdate").addEventListener("tap",function(){
						plus.runtime.getProperty(plus.runtime.appid,function(inf){
					        var version = inf.version;
					        console.log("当前应用版本："+version);
					        app.checkUpdate(version,false);
					    });
					});
			});
			
			
	
			
		</script>
	</head>

	<body>
		<div class="mui-content ">
		<div class="mui-text-center">

		<form class="mui-input-group">
		<div style="margin-top: 0px;">
				<span class="mui-icon mui-icon-person" style="font-size: 4em; border: 2px solid gray; border-radius: 50%; color: gray;"></span>
			</div>
			<br>
			<div class="mui-input-row">
				<label style="text-align:left;">姓名：</label><label id='user_name' style="text-align: center;"></label>
			</div>
		     <div class="mui-input-row ">
				<label style="text-align:left;">工号：</label><label id='login_name' style="text-align: center;"></label>
			</div>
			<div class="mui-input-row">
				<label style="text-align:left;">公司：</label><label id='coop_name' style="text-align: center;"></label>
			</div>
		</form>
			</div>
			<ul class="mui-table-view" style="margin-top: 10px;">
			<li id="change_pass" class="mui-table-view-cell">
					<a class="mui-navigate-right" >
						<i class="fa fa-lock" aria-hidden="true"></i> 修改密码
					</a>
				</li>
			</ul>
			<ul class="mui-table-view" style="margin-top: 10px;">
			<li id="change_pass" class="mui-table-view-cell">
					<a class="mui-navigate-right" >
						<i class="fa fa-question-circle-o" aria-hidden="true"></i> 帮助
					</a>
				</li>
				
				<li id="checkUpdate" class="mui-table-view-cell">
					<a class="mui-navigate-right" >
						<i class="fa fa-cloud-download"></i> 版本更新
					</a>
				</li>
			</ul>
			
		<form id='login-form' class="mui-input-group">
			<div class="mui-content-padded"  style="margin-bottom: 5px;">
				<button id='login_out' class="mui-btn mui-btn-block mui-btn-red">退出</button>

			</div>
		</form>
			
		</div>

	</body>

</html>